package jmine.tec.web.wicket.component.command.img;

import images.ImageResources;

import java.io.Serializable;

import org.apache.wicket.Page;
import org.apache.wicket.ResourceReference;
import org.apache.wicket.markup.html.WebPage;

/**
 * {@link ImageCommand} que representa um botão para a {@link WebPage} informada.
 * 
 * @author diego.ferreira
 * @date Mar 20, 2012
 */
public class PageLinkImageCommand extends AbstractImageCommand {

    private String image;

    private WebPage page;

    private ResourceReference resourceReference;

    /**
     * Construtor.
     * 
     * @param image imagem a ser renderizada no link.
     * @param page {@link WebPage} destino para o link.
     */
    public PageLinkImageCommand(WebPage page, String image) {
        this.page = page;
        this.image = image;
        this.resourceReference = new ResourceReference(ImageResources.class, this.image);
    }

    /**
     * Construtor
     * 
     * @param page {@link WebPage} destino para o link.
     * @param resourceReference {@link ResourceReference}.
     */
    public PageLinkImageCommand(WebPage page, ResourceReference resourceReference) {
        this.page = page;
        this.resourceReference = resourceReference;
    }

    /**
     * {@inheritDoc}
     */
    public ResourceReference getImage() {
        return this.resourceReference;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Page execute(Serializable commandParam) {
        return this.page;
    }
}
